app.controller('sys_configEditController', ['$scope', 'httpWrapService', 'dialogs', '$state', '$stateParams',
                        '$location', '$anchorScroll', 'AlertFactory','validationService',
                function ($scope, httpWrapService, dialogs, $state, $stateParams, $location, $anchorScroll, AlertFactory,validationService) {
	 $scope.entity = {};

	    $scope.id = $stateParams.id;
	    $scope.type = $stateParams.type || 'add';
	    $scope.Alert = AlertFactory.newInstance();

	    if($scope.id) {
	        httpWrapService.post('system/config/view/' + $scope.id + '.do').then(function (res) {
	            $scope.entity = res.data.entity;
	            $scope.type = 'update';
	        });
	    }

	    $scope.save = function () {
	        httpWrapService.defaultSave( 'system/config/' + $scope.type + '.do',{
	            entity : $scope.entity
	        }, $scope).then(function (res) {
	            $state.go('app.system.config.list');
	        });
	        // 保存成功返回列表页面
	    }
	    $scope.canle = function () {
	        // 后退到列表页面
	        $state.go('app.system.config.list');
	    }

}]);
